package com.oscarmovie.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oscarmovie.model.Calendar;
import com.oscarmovie.model.Movie;

public class CalendarDaoImpl extends HibernateDaoSupport implements CalendarDao {

	public void save(Calendar movie) {
		getSession().saveOrUpdate(movie);
	}

	public Calendar load(int id) {
		Calendar calendar = (Calendar)getSession().load(Calendar.class, id);
		return calendar;
	}
	
	
	public List<Calendar> loadAll() {
		Query query = getSession().createQuery("from Calendar order by id desc");
		query.setCacheable(true);
		List<Calendar> list = (List<Calendar>)query.list();
		return list;
	}
	
}
